package bat.ke.qq.com.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Fox
 */
@RestController
/**
 * @RefreshScope 是替换掉配置bean,  @Scheduled注解就不生效了，
 * fox老师说IndexController这个bean就成了懒加载了，需要主动才能去触发
 */
@RefreshScope
public class IndexController {

    @Value("${common.age}")
    private String age;
    @Value("${common.name}")
    private String name;

    @GetMapping("/index")
    public String hello() {
        return name+","+age;
    }

    @Scheduled(fixedDelay = 10000)
    public void run() {

    }
}
